package com.yunji.product.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.product.bo.AttrValuesListQueryBO;
import com.yunji.product.dao.IAttrValuesDao;
import com.yunji.product.domain.AttrValuesDO;
import com.yunji.product.mapper.AttrValuesMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AttrValuesDaoImpl extends BaseDaoImpl<AttrValuesMapper, AttrValuesDO> implements IAttrValuesDao {
    @Override
    public boolean deleteByAttrIds(Long... attrIds) {
        return remove(new LambdaQueryWrapper<AttrValuesDO>()
                .in(AttrValuesDO::getAttrId, attrIds));
    }

    @Override
    public List<AttrValuesDO> search(AttrValuesListQueryBO bo) {
        return list(new LambdaQueryWrapper<AttrValuesDO>()
                .eq(BeanUtils.isNotNull(bo.getAttrId()), AttrValuesDO::getAttrId, bo.getAttrId())
                .eq(BeanUtils.isNotNull(bo.getValueId()), AttrValuesDO::getValueId, bo.getValueId()));
    }
}
